package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * @Classname: WriteStringDemo
 * @Author: bromide
 * @CreateTime: 2022/3/28--15:25
 * @Version: V1.0
 * @Desciption: 向文件中写入文本数据
 */
public class WriteStringDemo {
    public static void main(String[] args) throws IOException {
        //向文件中写入文本数据
        FileOutputStream fos = new FileOutputStream("fos.txt", true);//后面加true就是追加模式，再次运行时不会重置文件
        String line = "你在干嘛？";
        byte[] data = line.getBytes(StandardCharsets.UTF_8);
        fos.write(data);
        System.out.println("写出完成！");

    }
}
